<template>

	<view class="library_item" @click="goDetail(item)">
		<view class="header">
			<image src="../../static/go.png" mode="aspectFill"></image>
		</view>
		<view class="cont">
			<view class="user_name">{{item.nickname || '官方出品'}}</view>
			<view class="text_area">{{item.name}}</view>
			<template v-if="item.img?true:false">
				<view class="imgs small_img" v-if="item.img.split(',').length> 1"
					@click.stop="seeImg(itemIndex,item.img)">
					<image class="img_view" :src="imgItem" v-for="(imgItem, itemIndex) in item.img.split(',')"
						:key="index"></image>
				</view>
				<view class="imgs" v-else>
					<image class="img_view" :src="item.img" mode="widthFix"></image>
				</view>
			</template>

			<view class="class_type" v-if="item.source_type_name || item.type">
				<view class="type_name">#{{(item.source_type_name || item.type_name) || ''}}</view>
			</view>
			<view class="opt_btn" v-if="optVisible">
				<view class="btn_item">
					<!-- e732 -->
					<view class="iconfont iconfont-e733"></view>
					<view class="tip_box">
						<!-- <view class="num">6</view> -->
						<view class="tip">收藏</view>
					</view>
				</view>
				<view class="btn_item">
					<view class="iconfont iconfont-e635"></view>
					<view class="tip_box">
						<!-- <view class="num">135</view> -->
						<view class="tip">下载图文</view>
					</view>
				</view>
				<view class="btn_item">
					<view class="wx iconfont iconfont-e606"></view>
					<view class="tip_box">
						<!-- <view class="num">119</view> -->
						<view class="tip">分享</view>
					</view>
				</view>
			</view>
		</view>
	</view>

</template>

<script>
	export default {
		props: {
			item: {
				type: Object,
				default: () => {
					return {}
				}
			},
			optVisible: {
				type: Boolean,
				default: true
			}, // 是否列表页
		},
		data() {
			return {

			}
		},
		methods: {
			goDetail(item) {
				if (this.optVisible) {
					this.$linkTo(`/package/league/articleLibrary/index?id=${item.pk_id}`)
				}
			},
			seeImg(index, img) {
				if (!this.optVisible) {
					uni.previewImage({
						current: index,
						urls: img.split(',')
					})
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.library_item {
		padding: 28rpx 30rpx 0;
		border-bottom: 2rpx solid #e5e5e5;
		display: flex;

		&:last-of-type {
			border-bottom: none;
		}

		.header {
			width: 84rpx;
			height: 84rpx;
			border-radius: 50%;
			overflow: hidden;
			margin-right: 30rpx;
		}
	}

	.cont {
		padding-top: 6rpx;
		flex: 1;
		overflow: hidden;

		.user_name {
			color: #575C6F;
			font-size: 30rpx;
		}

		.text_area {
			font-size: 26rpx;
			line-height: 38rpx;
			margin-top: 8rpx;
		}

		.imgs {
			padding-top: 20rpx;
			display: flex;
			flex-wrap: wrap;

			.img_view {
				margin: 14rpx 14rpx 0 0;
				width: 416rpx;
			}

			&.small_img {
				.img_view {
					width: 166rpx;
					height: 166rpx;
				}
			}
		}

		.class_type {
			display: flex;

			.type_name {
				background-color: #f6f6f6;
				margin-top: 22rpx;
				padding: 10rpx 24rpx;
				border-radius: 10rpx;
				font-size: 24rpx;
			}
		}

		.opt_btn {
			display: flex;
			justify-content: space-between;
			padding-right: 30rpx;
			padding: 20rpx 0;

			.btn_item {
				display: flex;
				align-items: center;

				.iconfont {
					color: #292929;
					font-size: 46rpx;
					margin-right: 12rpx;

					&.wx {
						color: #3AAA22;
					}
				}

				.tip_box {
					color: #888;
					font-size: 22rpx;

					// .tip {
					// 	margin-top: 4rpx;
					// }
				}
			}
		}
	}
</style>
